package history.alibaba1.problem2;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 *
 */
public class Main {
    private static int[][] route;
    private static Map<Integer, Integer> routeMap;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int hotelNum = sc.nextInt();
        sc.nextLine();
        route = new int[hotelNum][hotelNum];
        routeMap = new HashMap<>();
        // 算出每个点到其他所有点的距离
        while(hotelNum -- > 0){
            String[] curEdge = sc.nextLine().split(" ");
            int[] edgeArray = new int[3];
            for (int i = 0; i < 3; i++) {
                edgeArray[i] = Integer.parseInt(curEdge[i]);
            }
            route[edgeArray[0]][edgeArray[1]] = edgeArray[2];
            route[edgeArray[1]][edgeArray[0]] = edgeArray[2];
            routeMap.put(edgeArray[0], edgeArray[1]);
            routeMap.put(edgeArray[1], edgeArray[0]);
        }
        for (int i = 0; i < hotelNum; i++) {
            route[i][i] = 0;
        }
        // 由可达矩阵计算路径, 首先肯定没有环, 每个点到别的点只有一条路径
        int myChoose = sc.nextInt();
        int[] myChooseArray = new int[myChoose];
        int count = 0;
        while(myChoose -- > 0){
            myChooseArray[count++] = sc.nextInt();
        }
        int aChoose = sc.nextInt();
        int[] aChooseArray = new int[myChoose];
        count = 0;
        while(myChoose -- > 0){
            aChooseArray[count++] = sc.nextInt();
        }
        int bChoose = sc.nextInt();
        int[] bChooseArray = new int[myChoose];
        count = 0;
        while(myChoose -- > 0){
            bChooseArray[count++] = sc.nextInt();
        }
        double sum = 0;
        for(int i: myChooseArray){
            for(int j: aChooseArray){
                for(int k: bChooseArray){
                    sum += (double)getMinRoute(i, j, k);
                }
            }
        }
        System.out.println(sum / (myChooseArray.length * aChooseArray.length * bChooseArray.length));
    }
    // 广度优先搜索找一下路程
    public static int getMinRoute(int i, int j, int k){
        int min = Integer.MAX_VALUE;
        int curRoute = 0;
        for(int curHotel = 0; curHotel < route.length; curHotel++){
            curRoute = getRoute(curHotel, i) + getRoute(curHotel, j) + getRoute(curHotel, k);
            min = Math.min(curRoute, min);
        }

        return min;
    }
    public static int getRoute(int curHotel, int target){

        return -1;
    }
}
